package com.demo.service.impl;
import com.demo.api.model.User;
import com.demo.resource.UserMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;



@Service
public class TestThreadService  {

	private Logger logger = LoggerFactory.getLogger(TestThreadService.class);

	@Autowired
	private UserMapper userMapper;

	// 通过@Async注解方法表明这个方法是一个异步方法，如果注解在类级别，则表名该类的所有方法都是异步的，
	// 而这里的方法自动被注入使用ThreadPoolTaskExecutor作为TaskExecutor
	@Async
	public void executeAsyncTask( User detail) {
		User result= userMapper.getById(detail.getId());
		logger.info("==========================="+result.getId()+"============================");
	}

}